fix(trace): convert file path to URI in StdinServer._loadTrace#39097
Closed
li-zhixin wants to merge 1 commit intomicrosoft:mainfrom
Closed
fix(trace): convert file path to URI in StdinServer._loadTrace#39097li-zhixin wants to merge 1 commit intomicrosoft:mainfrom
li-zhixin wants to merge 1 commit intomicrosoft:mainfrom
Conversation
When receiving trace paths via stdin (used by VS Code extension), StdinServer._loadTrace() was sending raw file paths to the frontend instead of converting them to `file?path=` URI format. This caused the trace viewer to fail with "Not allowed to load local resource: file:///" error because the Service Worker tried to fetch the raw path directly. The fix calls validateTraceUrl() to properly convert the file path to URI format before sending to the frontend, consistent with how other entry points (runTraceViewerApp, runTraceInBrowser) handle trace paths. Fixes microsoft#39096
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fix trace viewer failing when receiving trace paths via stdin (used by VS Code extension for live trace).
StdinServer._loadTrace()now callsvalidateTraceUrl()to convert file paths tofile?path=URI formatrunTraceViewerApp()andrunTraceInBrowser()Problem
After #38566, the trace viewer expects trace URIs in
file?path=...format, butStdinServer._loadTrace()was still sending raw file paths. This caused the Service Worker to attempt fetching the raw path directly, resulting in:Root Cause
In commit 185bfb7,
validateTraceUrl()was updated to convert file paths to URI format, butStdinServer._loadTrace()was not updated to use this function.Fix
private _loadTrace(traceUrl: string) { - this._traceUrl = traceUrl; + const validatedUrl = validateTraceUrl(traceUrl); + this._traceUrl = validatedUrl; clearTimeout(this._pollTimer); - this.sendEvent?.('loadTraceRequested', { traceUrl }); + this.sendEvent?.('loadTraceRequested', { traceUrl: validatedUrl }); }Test Plan
Fixes #39096